package com.only4play.practice.invoice.core.facade;

import com.only4play.practice.common.BizCodeEnum;
import com.only4play.practice.common.exception.BizException;
import com.only4play.practice.common.model.RespWrapper;
import com.only4play.practice.objectsku.api.feign.ObjectSkuFeign;
import com.only4play.practice.objectsku.api.model.resp.ObjectSkuResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
@RequiredArgsConstructor
public class OrderFacadeServiceImpl implements IOrderFacadeService{

  private final ObjectSkuFeign objectSkuFeign;

  @Override
  public ObjectSkuResponse findSkuInfoById(Long skuId) {
      RespWrapper<ObjectSkuResponse> respWrapper = objectSkuFeign.findById(skuId);
      if (Objects.equals(respWrapper.getCode(), BizCodeEnum.CODE_SUCCESS.getCode())){
          return respWrapper.getData();
      }else {
        throw new BizException(BizCodeEnum.NotFindError);

      }
  }
}
